<!--  -->
<template>
  <div>
     <nav-bar>
      <div slot="left" class="backimg" @click="backClick"><img src="~assets/img/common/fanhui.png" ></div>
      <!-- <img src="" alt=""> -->
      <div slot="center" class="title">
        <div class="title-item" 
        :class="{active: index === currentIndex}" 
        v-for="(item, index) in titles" 
        :key="index" 
        @click="titleClick(index)" >
        {{item}}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>

import NavBar from 'components/common/navbar/NavBar';
export default {
  name: 'DetailNavBar',
  data() {
    return {
      titles: ['商品', '参数', '评论', '推荐'],
      currentIndex: 0
    }
  },
  components: {
    NavBar
  },
  // 生命周期 - 创建完成（访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted() {

  },
  methods: {
    titleClick(index) {
      this.currentIndex = index;
      this.$emit('titleClick', index)
    },
    backClick() {
      this.$router.back()
    }
  }
}
</script>
<style scoped>
/* @import url(); 引入css类 */
.backimg {
  width: 44px;
  height: 44px;
}
.backimg img {
  width: 100%;
}
.title {
  display: flex;
  font-size: 14px;
}
.title-item {
  flex: 1;
}
.active {
  color: var(--color-high-text);
}
</style>
